<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>认证中心</title>
		<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0" />
		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<link rel="stylesheet" href="../static/css/common/reset.min.css" />
		<link rel="stylesheet" href="../static/font_style/iconfont.css" />
		<link rel="stylesheet" href="../static/css/user/certification_center.css?v=4" />
		<link rel="stylesheet" href="../static/css/common/mui.min.css" />

		<body>
			<div class="certification-center">
				<div class="certification-center-title">请填写真实信息完成基础认证</div>
				<div class="certification-center-list1">
					<ul class="realName clearfix vest" data="">
						<li class="certificate-img1"></li>
						<li>
							<img src="../static/img/ic_real name.png?v=1">
							<p>实名认证</p>
						</li>
						<li>
							<div class="certification-state">
								<span class="status-text"></span>
								<svg class="icon1" aria-hidden="true">
									<use xlink:href="#icon-you"></use>
								</svg>
							</div>
						</li>
					</ul>
					<ul class="liveness clearfix vest" data="">
						<li class="certificate-img7"></li>
						<li>
							<img src="../static/img/ic_face.png?v=1">
							<p>人脸识别</p>
						</li>
						<li>
							<div class="certification-state">
								<span class="status-text"></span>
								<svg class="icon1" aria-hidden="true">
									<use xlink:href="#icon-you"></use>
								</svg>
							</div>
						</li>
					</ul>
					<ul class="userDetails clearfix vest">
						<li class="certificate-img2"></li>
						<li>
							<img src="../static/img/ic_personal information.png?v=1">
							<p>个人信息</p>
						</li>
						<li>
							<div class="certification-state">
								<span class="status-text"></span>
								<svg class="icon1" aria-hidden="true">
									<use xlink:href="#icon-you"></use>
								</svg>
							</div>
						</li>
					</ul>
					<ul class="mobile clearfix vest">
						<li class="certificate-img6"></li>
						<li>
							<img src="../static/img/ic_phone.png">
							<p>手机认证</p>
							<div class="fee_question" onclick="explain(0,event)">
								<img src="../static/img/ic_problem.png">
							</div>
						</li>
						<li>
							<div class="certification-state mobile_renzheng">
								<span class="status-text"></span>
								<svg class="icon1" aria-hidden="true">
									<use xlink:href="#icon-you"></use>
								</svg>
							</div>
						</li>
					</ul>
					<ul class="alipay clearfix vest" data="true">
						<li class="certificate-img7"></li>
						<li>
							<img src="../static/img/ic_Alipay.png?v=1">
							<p>支付宝</p>
							<div class="fee_question" onclick="explain(1,event)" style="margin-left: 0.23rem;">
								<img src="../static/img/ic_problem.png">
							</div>
						</li>
						<li>
							<div class="certification-state">
								<span class="status-text"></span>
								<svg class="icon1" aria-hidden="true">
									<use xlink:href="#icon-you"></use>
								</svg>
							</div>
						</li>
					</ul>
					<!--高级认证-->
					<div class="advanced" style="display: none;">
						<p class="title">完成以下认证可获取更高额度</p>
						<ul class="email clearfix vest">
							<li class="certificate-img2"></li>
							<li>
								<img src="../static/img/ic_email.png?v=1">
								<p>邮箱认证</p>
							</li>
							<li>
								<div class="certification-state">
									<span class="status-text"></span>
									<svg class="icon1" aria-hidden="true">
										<use xlink:href="#icon-you"></use>
									</svg>
								</div>
							</li>
						</ul>
						<ul class="shebao clearfix vest">
							<li class="certificate-img2"></li>
							<li>
								<img src="../static/img/ic_providentfund.png?v=1">
								<p>社保认证</p>
							</li>
							<li>
								<div class="certification-state">
									<span class="status-text"></span>
									<svg class="icon1" aria-hidden="true">
										<use xlink:href="#icon-you"></use>
									</svg>
								</div>
							</li>
						</ul>
						<ul class="fund clearfix vest">
							<li class="certificate-img2"></li>
							<li>
								<img src="../static/img/ic_socialsecurity.png?v=1">
								<p>公积金认证</p>
							</li>
							<li>
								<div class="certification-state">
									<span class="status-text"></span>
									<svg class="icon1" aria-hidden="true">
										<use xlink:href="#icon-you"></use>
									</svg>
								</div>
							</li>
						</ul>
					</div>
				</div>
				<div class="hint" style="display: none;">
					<div class="list">
						<div class="div shou" style="display: none;">
							<p>手机认证说明</p>
							<ul>
								<li>1.认证过程一般在1分钟左右，请耐心等待；</li>
								<li>2.长时间显示认证中，退出认证页面然后重新查看或者提交意见反馈给客服。 </li>
							</ul>
							<button class="">知道了</button>

						</div>
						<div class="div zhi" style="display: none;">
							<p>支付宝认证说明</p>
							<ul>
								<li>方法一：【支付宝账号密码登录】；</li>
								<li>方法二：左下角绑定的【淘宝会员账号密码登录】；</li>
								<li>方法三：扫描二维码登录。</li>
							</ul>
							<span>注：一般认证需1分钟左右，请耐心等待。</span>
							<button class="">知道了</button>
						</div>
					</div>
				</div>
				<div class="borrow-btn">
					<button class="borrow-word" style="border:none;display:block;">完成</button>
				</div>
				<p class="footer"><img src="../static/img/ic_safe.png" />银行级数据加密</p>
				<p class="footer_text">永康市中领小额贷款有限公司</p>
			</div>
			<script src="../static/js/common.js?v=1"></script>
			<script src="../static/js/common/jquery.min.js"></script>
			<script src="../static/font_style/iconfont.js"></script>
			<script src="../static/js/common/mui.min.js"></script>
			<script src="../static/js/bridge.js"></script>
			<script>
				var domain = apiDomain();
				var webUrl = webDomain();
				var bindbank;
				var items = ['realName', 'liveness', 'userDetails', 'mobile', 'alipay', 'email', 'shebao', 'fund'];
				var items_name = {
					'realName': "实名认证",
					'liveness': "人脸识别",
					'userDetails': "个人信息认证",
					'mobile': "手机认证",
					'alipay': "支付宝认证",
					'email': '邮箱认证',
					'shebao': '社保认证',
					'fund': "公积金认证"
				};

				try {
					setInterval(function() {
						initInfo();
					}, 5000);
				} catch(e) {
					//TODO handle the exception
				}
				initInfo();

				function initInfo() {
					var token = getToken();
					$.ajax({
						type: "post",
						url: domain + "user_ident_info",
						dataType: "json",
						data: {
							token: token
						},
						success: function(data) {
							if(data.status == 4002) {
								closeAndOpen(0);
								closeAndOpen(1);
								return;
							}
							items.forEach(function(item) {
								$("." + item).find(".status-text").html(getStatusText(data.data[item]));
								$("." + item).attr("data", data.data[item]);
							});
							bindbank = data.data.bindbank;
						}
					});
				}

				function getStatusText(status) {
					if(status == 0) {
						return "<font style='color: #F5A623;'>未认证</font>";
					}
					if(status == 1) {
						return "<font style='color: #7ED321;'>认证中</font>";
					}
					if(status == 2) {
						return "认证成功";
					}
					if(status == 3) {
						return "<font style='color: #F4492B;'>认证失败</font>";
					}
					if(status == 4) {
						return "<font style='color: #F4492B;'>认证过期</font>";
					}

				}

				//实名认证
				$(".realName").click(this, function() {
					if($(this).attr("data") == 2) {
						closeAndOpen(5);
						return;
					}
					closeAndOpen(5);
					initInfo();
				});

				//人脸识别
				$(".liveness").click(function() {
					if($(this).attr("data") == 2) {
						closeAndOpen(6);
						return;
					}
					closeAndOpen(6);
					initInfo();
				});

				// 个人信息
				$(".userDetails").click(function() {
					if($(this).attr("data") == 2) {
						closeAndOpen(7)
						return;
					}
					closeAndOpen(7);
					initInfo();
				});

				//手机认证
				$(".mobile").click(function() {
					if($(this).attr("data") == 2) {
						mui.alert("手机认证已经通过了")
						return;
					}
					if($(this).attr("data") == 1) {
						mui.alert("正在认证中，稍后再试")
						return;
					}
					if($(".realName").attr("data") != 2) {
						mui.toast("请先完成实名认证")
						return
					}
					if($(".liveness").attr("data") != 2) {
						mui.toast("请先完成人脸识别")
						return
					}
					if($(".userDetails").attr("data") != 2) {
						mui.toast("请先完成个人信息认证")
						return
					}
					var token = getToken();
					$.ajax({
						type: "post",
						url: domain + "user_ident_info",
						dataType: "json",
						data: {
							token: token
						},
						success: function(data) {
							if(data.status == 4002) {
								closeAndOpen(0);
								closeAndOpen(1);
								return;
							}
							items.forEach(function(item) {
								$("." + item).find(".status-text").html(getStatusText(data.data[item]));
								$("." + item).attr("data", data.data[item]);
							})
							bindbank = data.data.bindbank;
							if(data.data.mobile == 2) {
								mui.alert("手机认证已通过");
								return;
							}
							if(data.data.mobile == 1) {
								mui.alert("正在认证中，稍后再试");
								return;
							}
							closeAndOpen(8);
							initInfo();
						}
					});
				});

				//支付宝认证
				$(".alipay").click(function() {
					if($(this).attr("data") == 2) {
						mui.alert("支付宝认证已经通过了")
						return;
					}
					if($(this).attr("data") == 1) {
						mui.alert("正在认证中，稍后再试")
						return;
					}
					if($(".realName").attr("data") != 2) {
						mui.toast("请先完成实名认证")
						return
					}
					if($(".liveness").attr("data") != 2) {
						mui.toast("请先完成人脸识别")
						return
					}
					if($(".userDetails").attr("data") != 2) {
						mui.toast("请先完成个人信息认证")
						return
					}
					if($(".mobile").attr("data") != 2) {
						mui.toast("请先完成手机认证")
						return
					}
					var token = getToken();
					$.ajax({
						type: "post",
						url: domain + "user_ident_info",
						dataType: "json",
						data: {
							token: token
						},
						success: function(data) {
							if(data.status == 4002) {
								closeAndOpen(0);
								closeAndOpen(1);
								return;
							}
							items.forEach(function(item) {
								$("." + item).find(".status-text").html(getStatusText(data.data[item]));
								$("." + item).attr("data", data.data[item]);
							})
							bindbank = data.data.bindbank;
							if(data.data.alipay == 2) {
								mui.alert("支付宝认证已通过");
								return;
							}
							if(data.data.alipay == 1) {
								mui.alert("正在认证中，稍后再试");
								return;
							}
							closeAndOpen(9);
							initInfo();
						}
					});
				});

				//邮箱认证
				$(".email").click(function() {
					if($(this).attr("data") == 2) {
						mui.alert("邮箱认证已经通过了")
						return;
					};
					if($(this).attr("data") == 1) {
						mui.alert("正在认证中，稍后再试")
						return;
					};
					for(var i = 0; i < items.length - 3; i++) {
						var status = $("." + items[i]).attr("data");
						if(status != 2) {
							mui.toast("请完成" + items_name[items[i]]);
							return;
						}
					};
					closeAndOpen(10);
					initInfo();
				});

				//社保认证
				$(".shebao").click(function() {
					if($(this).attr("data") == 2) {
						mui.alert("社保认证已经通过了")
						return;
					};
					if($(this).attr("data") == 1) {
						mui.alert("正在认证中，稍后再试")
						return;
					};
					for(var i = 0; i < items.length - 3; i++) {
						var status = $("." + items[i]).attr("data");
						if(status != 2) {
							mui.toast("请完成" + items_name[items[i]]);
							return;
						}
					};
					closeAndOpen(11);
					initInfo();
				});

				//公积金认证
				$(".fund").click(function() {
					if($(this).attr("data") == 2) {
						mui.alert("公积金认证已经通过了")
						return;
					};
					if($(this).attr("data") == 1) {
						mui.alert("正在认证中，稍后再试");
						return;
					};
					for(var i = 0; i < items.length - 3; i++) {
						var status = $("." + items[i]).attr("data");
						if(status != 2) {
							mui.toast("请完成" + items_name[items[i]]);
							return;
						}
					};
					closeAndOpen(12);
					initInfo();
				});

				$(".borrow-word").click(function() {
					var ua = navigator.userAgent.toLowerCase();
					//					var email = $(".email").attr("data");
					//					var shebao = $(".shebao").attr("data");
					//					var fund = $(".fund").attr("data");

					for(var i = 0; i < items.length - 3; i++) {
						var status = $("." + items[i]).attr("data");
						if(status != 2) {
							mui.alert("请完成" + items_name[items[i]])
							return;
						}
					};
					//					if(email == 2 || shebao == 2 || fund == 2) {
					if(bindbank == 2) {
						closeAndOpen(0);
					} else {
						if(/android/.test(ua)) {
							skipPage(1, webUrl + "user/bank_card_bind.html");
						} else {
							window.location.href = "bank_card_bind.html";
						};
					}
					//					} else {
					//						mui.alert("请选择其中一项完成高级认证");
					//						return;
					//					};
				});

				//手机支付宝说明
				function explain(x, event) {
					event.stopPropagation();
					$(".hint").stop().show().find(".div").eq(x).stop().show().siblings().hide();
				};

				$(".hint").click(function() {
					$(".hint").stop().hide();
				});
			</script>
		</body>

</html>